package inc.sneid.reminderSpring.services;

import inc.sneid.reminderSpring.domains.Record;
import inc.sneid.reminderSpring.repos.RecordRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class RecordService {

    private final RecordRepository recordRepository;

    public RecordService(RecordRepository recordRepository){
        this.recordRepository = recordRepository;
    }

    public Record save(Record record){
        return recordRepository.save(record);
    }

    public Optional<Record> getById(Long id){
        return recordRepository.findById(id);
    }

    public Page<Record> getPage(Pageable pageable){
        return recordRepository.findAll(pageable);
    }

    public void deleteById(Long id){
        recordRepository.deleteById(id);
    }

    public void delete(Record record){
        recordRepository.delete(record);
    }
}
